package com.spacing.app;

import java.util.ArrayList;

import com.senseilearning.spanish.R;
import com.spacing.app.data.Chapters;

import android.app.ListActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ChaptersViewActivity extends ListActivity {
	Chapters chapters;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chapters_list);
		Intent i = getIntent();
		chapters = (Chapters) i.getSerializableExtra("chapters");
		
		ArrayList<String> chapter_names = chapters.getNames();
		
		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, chapter_names));
		
		SharedPreferences sharedPreferences = getSharedPreferences("test",0);
		Toast.makeText(this, sharedPreferences.getString("MEM2", ""), 4000).show();
		
	}
	
	@Override
	public void onListItemClick(ListView parent, View v, int position, long id) {
		Intent intent = new Intent(this, ChapterViewActivity.class);
		intent.putExtra("chapters", chapters);
		intent.putExtra("chapter", position);
		startActivity(intent);
	}


	
}